const myChart = echarts.init(document.getElementById('test'));

// 指定图表的配置项和数据
myChart.setOption({
    title: {
        text: '本年度成果分布图'
    },
    tooltip: {
        trigger: 'axis'
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    legend: {
        data: []
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
        }
    ],
    yAxis: [
        {
            type: 'value'
        }
    ],
    series: [
    ]
});

myChart.showLoading();
$.get('/type/get', function (result1) {
    const legendElement = result1.payload.map(t => t.name)
    myChart.setOption({legend: {
            data: legendElement
        }})
    $.get('/result/get/year', function (result2) {
        let seriesList = [];
        for (let one in result2.payload) {
            let data = [];
            for (let t in result2.payload[one]) {
                if (t != 12) {
                    data.push(result2.payload[one][t]);
                }
            }
            seriesList.push({
                name: result2.payload[one][12],
                type: 'line',
                data: data
            })
        }
        myChart.hideLoading()
        myChart.setOption({series: seriesList})
    })
})